module AdminwebsitearticlesHelper
  def category_column(record) 
    if record.category.nil? 
      "" 
    else 
      record.category.name 
    end 
  end 


  # display the category column as a dropdown 
  def category_form_column(record,input_name) 
    options = Category.find(:all).collect do |c| 
      [ c.name, c.id ] 
    end 
    select :record, :category_id, options, 
           {:include_blank => false, :prefix => input_name}, 
           {:name => input_name + '[id]'} 
  end 
  
  def last_updated_at_column(record) 
    if record.last_updated_at.nil? 
      "" 
    else   
      record.last_updated_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
  def last_accessed_at_column(record)    
    if record.last_accessed_at.nil? 
      "" 
    else
      record.last_accessed_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
  def published_at_column(record)    
    if record.published_at.nil? 
      "" 
    else
      record.published_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
 def body_form_column(record, input_name)
	text_area :record, :body, :name  =>  input_name,:cols => 120, :rows => 30, :class  =>  :tiny_mce, :style  =>  "height:auto;"
 end
  def synopsis_column(record)
	 sanitize(record.synopsis)
	end  
  
  def body_column(record)
	 sanitize(record.body)
	end 
	
  def user_published_by_form_column(record,input_name) 
  
   if logged_in_user.has_role?('administrator')


		    options = Ualia.find(:all).collect do |c| 
		      [ c.name, c.name ] 
		    end 
		    select :record, :user_published_by, options, 
           {:include_blank => false}

   end      
  end
end
